﻿namespace TheSafety.Dialogs
{
    using Agent;
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.IO;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Markup;
    using System.Xml.Linq;

    [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
    public class NewsWindow : Window, IComponentConnector
    {
        internal TextBlock a;
        private bool b;

        public NewsWindow()
        {
            this.InitializeComponent();
            base.Title = e.c("NewsWindow");
        }

        [EditorBrowsable(EditorBrowsableState.Never), DebuggerNonUserCode]
        private void a(int A_0, object A_1)
        {
            switch (A_0)
            {
                case 1:
                    ((NewsWindow) A_1).Loaded += new RoutedEventHandler(this.Window_Loaded);
                    return;

                case 2:
                    this.a = (TextBlock) A_1;
                    return;
            }
            this.b = true;
        }

        [DebuggerNonUserCode]
        public void InitializeComponent()
        {
            if (!this.b)
            {
                this.b = true;
                Uri resourceLocator = new Uri("/TheSafety;component/dialogs/newswindow.xaml", UriKind.Relative);
                Application.LoadComponent(this, resourceLocator);
            }
        }

        private void Window_Loaded(object A_0, RoutedEventArgs A_1)
        {
            if (File.Exists(ConfigManager.q() + "/settings/news.xml"))
            {
                foreach (XElement element in XDocument.Load(ConfigManager.q() + "/settings/news.xml").Element("newsdata").Descendants("news").Reverse<XElement>())
                {
                    this.a.Inlines.Add(new Bold(new System.Windows.Documents.Run(element.Attribute("lacaldate").Value)));
                    this.a.Inlines.Add(new LineBreak());
                    this.a.Inlines.Add(new System.Windows.Documents.Run(element.Value));
                    this.a.Inlines.Add(new LineBreak());
                }
            }
            else
            {
                this.a.Inlines.Add(new System.Windows.Documents.Run(e.c("NoNews")));
                this.a.Inlines.Add(new LineBreak());
            }
        }
    }
}

